<?php
      $host = 'localhost:3306' ;
      $user = 'root' ;
      $pwd = 'root' ;
      $dbname = 'test2212' ;
      // 连接数据库
      $con = mysqli_connect($host , $user , $pwd , $dbname) ;
  
      if(!$con) {
          die('数据库连接失败') ;    // 结束整个php语句
      }


    $res = [];


    // 前端携带参数  cart_id
    $id = $_GET['id'] ;
    
    if($id) {
        // 
        $sql = "DELETE FROM cart WHERE cart_id = $id" ;
        $a = mysqli_query($con , $sql) ;   // 得到的就是数字
        if($a > 0) {
            $res['status'] = true ;
            $res['msg'] = '删除成功';
        } else {
            $res['status'] = false ;
            $res['msg'] = '数据库错误'; 
        }
    } else {
        $res['status'] = false ;
        $res['msg'] = '前端数据有误';
    }

    echo(json_encode($res));
